package com.lanou.web.controller;

import com.lanou.service.HomeShowService;
import com.lanou.utils.ShiHuiResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * Created by QuChao on 2018/11/29
 */
@RestController
@RequestMapping("/goods")
public class HomeShowController {
    @Autowired
    private HomeShowService homeShowService;

    @GetMapping("/home")
    public Map<String, Object> getHomeContent() {
        List<Map<String, Object>> list = homeShowService.getHomeContent();
        return list.size() != 0 ? ShiHuiResult.ok(list) : ShiHuiResult.error(400);
    }

    @GetMapping("/productDet")
    public Map<String, Object> getDescById(Long productId) {
        Map<String, Object> map = homeShowService.getDescById(productId);
        return map != null ? ShiHuiResult.ok(map) : ShiHuiResult.error(400);
    }

}
